<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="" class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" value="<?php echo $extension['name']; ?>" placeholder="请输入名称，可与分机号相同" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">分机号</label>
                <div class="layui-input-block">
                    <input type="number" disabled value="<?php echo $extension['extension']; ?>" class="layui-input layui-disabled">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="text" name="secret" value="<?php echo $extension['secret']; ?>" placeholder="请输入密码" lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="submitForm">确认</button>
                    <a href="<?php echo \yii\helpers\Url::to(['index']) ?>" class="layui-btn layui-btn-primary">返回列表</a>
                </div>
            </div>
        </form>
    </div>
</div>


<?php
$url = yii\helpers\Url::to(['edit','extension'=>$extension['extension']]);
$extension_index = yii\helpers\Url::to(['index']);
$js = <<<JS
    layui.use(['form','element','table', 'layer'],function() {
        var form = layui.form;  
        var element = layui.element;  
        var table = layui.table;  
        var layer = layui.layer;  
        
        //监听表单提交
        form.on('submit(submitForm)',function(data) {
            var where = data.field
            var index = layer.load()
            $.post("{$url}",where,function(res) {
                layer.close(index)
                layer.msg(res.msg,{},function() {
                    if (res.code==0){
                        location.href = '{$extension_index}'
                    }   
                })   
            })
            return false
        })
        
        
    });
JS;
$this->registerJs($js);
